//
//  PromptChatDateBase.h
//  SIPphone
//
//  Created by wrt on 13-12-3.
//  Copyright (c) 2013年 wrtsoft. All rights reserved.
//  即时聊天的数据库单例

#import <Foundation/Foundation.h>
#import <sqlite3.h>

//请求消息的宏定义

#define PROCHATTABLE_NAME @"prochatTable"
#define PROCHAT_USERNAME @"prochatUserName"
#define PROCHAT_IPPORT @"prochatIpPort"
#define PROCHAT_CONTENT @"prochatContent"
#define PROCHAT_ISTEXTORIMG @"prochatTextOrImg"
#define PROCHAT_ISOUTORCOME @"prochatOutOrCome"
#define PROCHAT_ISSUCCEED @"prochatSucceed"
#define PROCHAT_TIME @"prochatTime"
#define PROCHAT_ISREAD @"prochatIsRead"

@interface PromptChatDateBase : NSObject
{
    sqlite3 *db;
}

//用于存专门聊天窗口ID
@property (assign, nonatomic) unsigned long windowID;

//用户名数组
@property (strong, nonatomic) NSMutableArray *userNameArray;
//域名的数组
@property (strong, nonatomic) NSMutableArray *ipPortArray;
//是文本还是图像的数组
@property (strong, nonatomic) NSMutableArray *isTextOrImgArray;
//内容的数组
@property (strong, nonatomic) NSMutableArray *contentArray;
//是发送的还是接收的消息
@property (strong, nonatomic) NSMutableArray *isOutOrCome;
//是否发送成功
@property (strong, nonatomic) NSMutableArray *isSucceedArray;
//是否已读的数组
@property (strong, nonatomic) NSMutableArray *isReadArray;
//接收到的时间数组
@property (strong, nonatomic) NSMutableArray *timeArray;


//用于列表
//用户名数组
@property (strong, nonatomic) NSMutableArray *listUserNameArray;
//域名的数组
@property (strong, nonatomic) NSMutableArray *listIpPortArray;
//是文本还是图像的数组
@property (strong, nonatomic) NSMutableArray *listIsTextOrImgArray;
//内容的数组
@property (strong, nonatomic) NSMutableArray *listContentArray;
//是发送的还是接收的消息
@property (strong, nonatomic) NSMutableArray *listIsOutOrCome;
//是否发送成功
@property (strong, nonatomic) NSMutableArray *listIsSucceedArray;
//是否已读的数组
@property (strong, nonatomic) NSMutableArray *listIsReadArray;
//接收到的时间数组
@property (strong, nonatomic) NSMutableArray *listTimeArray;


//用于分页查询
//用户名数组
@property (strong, nonatomic) NSMutableArray *partUserNameArray;
//域名的数组
@property (strong, nonatomic) NSMutableArray *partIpPortArray;
//是文本还是图像的数组
@property (strong, nonatomic) NSMutableArray *partIsTextOrImgArray;
//内容的数组
@property (strong, nonatomic) NSMutableArray *partContentArray;
//是发送的还是接收的消息
@property (strong, nonatomic) NSMutableArray *partIsOutOrCome;
//是否发送成功
@property (strong, nonatomic) NSMutableArray *partIsSucceedArray;
//是否已读的数组
@property (strong, nonatomic) NSMutableArray *partIsReadArray;
//接收到的时间数组
@property (strong, nonatomic) NSMutableArray *partTimeArray;


//定义表名的属性
@property (strong, nonatomic) NSString *tableNameForUser;

//单例的初始化方法
+ (PromptChatDateBase *)sharePromptChatDB;

//创建数据库
- (void)creatDB;
//读取数据库
- (void)readDB;
//读取数据库用于聊天列表
- (void)readDBForlist;
//保存发送数据库
- (void)saveChatDBWithUserName:(NSString *)userName andIpPort:(NSString *)ipPort andContent:(NSString *)content andisTextOrImg:(NSString *)textOrImg andOutOrCome:(NSString *)outOrCome andIsSucceed:(int)succeed andIsRead:(int)read andTime:(NSString *)time;
//数据库删除
- (void)deleteChatDBWithUserName:(NSString *)userName andIpport:(NSString *)ipport;
//数据库更新（更新是否已读）
- (void)updateDBforReadWithUserName:(NSString *)userName andIpport:(NSString *)ipport;
//获取未读的条数
- (int)countForUnreadWith;
//用用户名和ip获取未读的条数
- (int)countForUnreadWithUserName:(NSString *)username andIpport:(NSString *)ip;
//用用户名和ip获取部分信息
- (void)readDBForpart:(NSString *)userName andIpport:(NSString *)ip andBeginNumber:(int)begin;

//切换表名
- (void)changeTableName:(NSString *)userName;
@end
